import pandas as pd
import plotly.graph_objects as go
import numpy as np
DEFAULT_PLOTLY_COLORS_RGB=['rgb(31, 119, 180)', 'rgb(255, 127, 14)',
'rgb(44, 160, 44)', 'rgb(214, 39, 40)',
'rgb(148, 103, 189)', 'rgb(140, 86, 75)',
'rgb(227, 119, 194)', 'rgb(127, 127, 127)',
'rgb(188, 189, 34)', 'rgb(23, 190, 207)']
DEFAULT_PLOTLY_COLORS_RGBA=['rgba(31, 119, 180, 0.2)', 'rgba(255, 127, 14, 0.2)',
'rgba(44, 160, 44, 0.2)', 'rgba(214, 39, 40, 0.2)',
'rgba(148, 103, 189, 0.2)', 'rgba(140, 86, 75, 0.2)',
'rgba(227, 119, 194, 0.2)', 'rgba(127, 127, 127, 0.2)',
'rgba(188, 189, 34, 0.2)', 'rgba(23, 190, 207, 0.2)']
probs=["MaF01", "MaF02", "MaF03", "MaF04", "MaF05",
"MaF06", "MaF07", "MaF08", "MaF09", "MaF10",
"MaF11", "MaF12", "MaF13", "MaF14", "MaF15"]
def plot_line_with_margin(alg, prob, color_index, pop_size, m, fig):
runs = [str(i) for i in range(0, 20)]
path="../MaFMethodology/%s/hhco/%s/%s/output/"%(m,alg,prob)
df = pd.read_csv(path+"HVI.csv")
df_mean = df.groupby(['it']).mean().reset_index()
df_max = df.groupby(['it']).max().reset_index()
df_min = df.groupby(['it']).min().reset_index()
x = df_mean['it'].tolist()
x_rev = x[::-1]
y1 = df_mean['HV'].tolist()
y1_upper = df_max['HV'].tolist()
y1_lower = df_min['HV'].tolist()
y1_lower = y1_lower[::-1]
fig.add_trace(go.Scatter(
x=x+x_rev,
y=y1_upper+y1_lower,
fill='toself',
fillcolor=DEFAULT_PLOTLY_COLORS_RGBA[color_index],
line_color='rgba(255,255,255,0)',
showlegend=False,
name=alg,
))
fig.add_trace(go.Scatter(
x=x, y=y1,
line_color=DEFAULT_PLOTLY_COLORS_RGB[color_index],
name=alg,
))
def plot_m(m, pop_size):
for prob in probs:
fig = go.Figure()
plot_line_with_margin('HHCOR2', prob, color_index=0, pop_size=pop_size, m=m, fig=fig)
plot_line_with_margin('HHCORandom', prob, color_index=1, pop_size=pop_size, m=m, fig=fig)
fig.update_traces(mode='lines')
fig.update_layout(title="%s(%s)"%(prob, m),
xaxis_title='Iteration',
yaxis_title='Hypervolume')
fig.update_layout(template="plotly_white")
fig.show()